Note: This tutorial assumes that you have completed the previous tutorials: s.
(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

Barcode-based object recognition

Description: This tutorial shows you how to extract a barcode from and image, store it into the barco ontology and query the ontology using knowrob

Tutorial Level: BEGINNER

In this tutorial you will learn how to extract a barcode from a focused image and from the barcode, get the object's information. Object information structured in a way that respects that barcoo ontology. Later on, you will be able to create instances of that object and query the Knowrob database. For more information please check Knowrob

Download of the necessary packages

To be able to perform the following commands, you should first be in your default ROS workspace.

Download the ias-perception package stack using the following command

git clone git@github.com:code-iai/ias_perception.git

Download the knowrob package stack using the following commands

git clone git@github.com:knowrob/knowrob.git

Package compilation

At this point you have all packages you need. Now you should build the packages using the following comands

roscd zbar_barcode_reader_node
rosmake
roscd comp_barcoo
rosmake

Package execution

Now that the packages are ready, you can start executing them. You will need three open terminal windows/tabs In terminal 1, you need to start ROS MASTER using the following command

roscore

In terminal 2, you need to launch the comp_barcoo service using the following commands

roscd comp_barcoo
cd bin
./barcoo_subscriber ../owl/barcoo_manual.owl ../data/barcoo_mapping.txt

The first argument is the path to barcoo.owl file which is OWL file where the barcoo ontology is stored.

The second argument is a 1-to-1 mapping between the category name of the object in the barcoo servers and the superclass of the object in the Barcoo ontology as stored in barcoo.owl.

In terminal 3, you need to launch the zbar_barcode_reader_node package using the following commands

roscd zbar_barcode_reader_node
cd bin
./zbar_image_reader ../data/03.jpg 0

The argument is the path to the image that will be decoded by zbar_barcode_reader_node. There are other images provided to you in the data folder.

Once you launch the last command you will see that the image has been decoded and its respective barcode number has been extracted, passed to comp_barcoo through the service called "send_barcode". Comp_barcoo at this point receives the barcode, checks if the object with that barcode exists in the database. If not, it connects to the Barcoo.com server, get the information about the object, stores it in the barcoo.owl ontology and creates a new instance with the name #barcode_#instance_number. Once the instance created, comp_barcoo will send back its name to zbar_barcode_reader_node

You can launch the last command more than once with the same image or different images. The result of launching the last command several times with the same image will create different instances of the same class. I advice you to do so as this will be useful for the next part.

Knowrob querying of the ontology

To query knowrob, we should first start by launching knowrob

roscd comp_barcoo
rosrun rosprolog rosprolog mod_vis
owl_parser:owl_parse('owl/barcoo_manual.owl', false, false, true).

At this point knowrob is launched and has been given the barcoo ontology through the file barcoo_manual.owl

The following part is a list of queries that can be provided to knowrob.

Assuming that you have launched zbar_barcode_reader_node by providing image 03.jpg, execute the following command.

owl_has(A, rdf:type, 'http://www.barcoo.com/barcoo.owl#4045145506129').

This should return something like this

A = 'http://ias.cs.tum.edu/kb/knowrob.owl#4045145506129_1' ;
A = 'http://ias.cs.tum.edu/kb/knowrob.owl#4045145506129_2' ;
A = 'http://ias.cs.tum.edu/kb/knowrob.owl#4045145506129_3' ;
true.

The result is the list of instances that exist of the object 4045145506129.The object's identifier is their barcode number.

Now that you have created instances of the class 4045145506129, you may want to know more information about the class such as the title, the producer etc... To do that try the following command

class_properties('http://www.barcoo.com/barcoo.owl#4045145506129', P, O).

Wiki: objects_of_daily_use_finder/Tutorials/Barcode-based object recognition (last edited 2013-06-24 15:34:51 by MoritzTenorth)